package com.zy.Redis;

//使用Redis做缓存,在页面显示省份信息，如果Redis中有数据，就直接输出，如果没有就查数据库并存储到Redis中
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/province")
public class provinceDemo extends HttpServlet
{
    private ProvinceService provinceService=new ProvinceServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        String province_json= provinceService.searchJson();
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(province_json);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        this.doPost(req,resp);
    }
}
